package com.ssm.sfzy.controller;

import com.ssm.sfzy.constant.CommonConstant;
import com.ssm.sfzy.entity.Article;
import com.ssm.sfzy.entity.ConsultWait;
import com.ssm.sfzy.service.ArticleService;
import com.ssm.sfzy.service.ConsultWaitService;
import com.ssm.sfzy.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @ClassName ConsultWaitController
 * @Description TODO
 * @Author Happy
 * @Date 2024年03月30日 16:58
 * @Version 1.0
 */
@RestController
@CrossOrigin
@RequestMapping("/consultWait")
public class ConsultWaitController {
    @Autowired
    private ConsultWaitService consultWaitService;

    @GetMapping("/find")
    public Object find(
            @RequestParam(defaultValue = CommonConstant.PAGE_NUM_DEFAULT) Integer pageNum,
            @RequestParam(defaultValue = CommonConstant.PAGE_SIZE_DEFAULT) Integer pageSize,
            ConsultWait consultWait
    ){
        Map<String, Object> map = consultWaitService.findPage(pageNum, pageSize, consultWait);
        return  Result.success(map);
    }


    @GetMapping("/findById/{id}")
    public Object findById(@PathVariable Integer id){
        ConsultWait consultWait = consultWaitService.findById(id);
        return Result.success(consultWait);
    }


    @PostMapping("/add")
    public Object add(@RequestBody ConsultWait consultWait) throws Exception {
        consultWaitService.add(consultWait);
        return Result.success();
    }

    @PutMapping("/edit")
    public Object edit(@RequestBody ConsultWait consultWait) throws Exception {
        consultWaitService.edit(consultWait);
        return Result.success();
    }
    @DeleteMapping("/remove/{id}")
    public Object remove(@PathVariable Integer id){
        consultWaitService.remove(id);
        return Result.success();
    }

    @DeleteMapping("/removeBatch")
    public Object removeBatch(Integer[] ids){
        consultWaitService.removeBatch(ids);
        return Result.success();
    }

}
